let vue = new Vue({
    el: '.main-content',
    data: {
        result: {},
        newApp: {}
    },
    methods: {
        select: function (pageNum, pageSize) {
            axios({
                url: `app/select/${pageNum}/${pageSize}`,
            }).then(rs => {
                this.result = rs.data.obj;
            })
        },
        toUpdate: function (id) {
            layer.appId = id;
            layer.message = '';
            layer.open({
                type: 2,
                title: false,
                area: ['80%', '80%'],
                content: 'app/upDateView',
                end: () => {
                    if (layer.message != '') {
                        layer.msg("更新成功");
                        this.select(1, 5);
                    }
                }
            })
        },
        deleteOne: function (id) {
            axios({
                url: `app/deleteOne/${id}`,
            }).then(rs => {
                if (rs.data >= 1) {
                    layer.msg("删除成功");
                    this.select(1, 5)
                } else {
                    layer.msg("删除失败")
                }
            })
        },
        insertOne: function () {
            axios({
                url: 'app/insertOne',
                method: 'post',
                data: this.newApp
            }).then(response => {
                if (response.data > 0) {
                    layer.msg("添加成功");
                    $("#versionList").click();
                    this.newApp = {};
                    this.select(1, 5)
                } else {
                    layer.msg("添加失败")
                }
            })
        },
        detailView: function (id) {
            layer.id=id;
            layer.message = '';
            layer.open({
                type: 2,
                title: false,
                area: ['80%', '80%'],
                content: 'app/detailHtml',
                end:()=>{

                }
            })
        }
    },
    created: function () {
        this.select(1, 5);
    }
});